package ynu.edu.api.client.fallback;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import ynu.edu.api.client.CartClient;

import java.util.Collection;

@Component
@Slf4j
public class CartClientFallbcakFactory implements FallbackFactory<CartClient> {
    @Override
    public CartClient create(Throwable cause) {
        return new CartClient() {
            @Override
            public void deleteCartItemByIds(Long userId, Collection<Long> ids) {
                log.error("购物车服务降级", cause);
                throw new RuntimeException("购物车服务降级");
            }
        };
    }
}
